%function [vq,varC]=MakeVQ(X,Ncodes);%creates and trains a Vector Quantizer for vectors in matrix X,%for minimum Euclidean square-sum distortion.%%Input:%X=     matrix with training vectors, stored column-wise%Ncodes=desired no of codebook vectors%       Ncodes must be <= size(X,2)/2%%Result:%vq=    new VQ object, adapted to given training data.%varC=  square deviations for each VQ cluster center%       size(varC)==size(C.CodeBook)%%Normally, size(vq.CodeBook,2) == Ncodes, BUT%CodeBook may be reduced during training, if a cluster is empty%	and then size(vq.CodeBook,2)<Ncodes%%Method: Generalized Lloyd algorithm is used%%This replaces old function MakeVqCodebook%%Arne Leijon 2006-05-01 tested.function [vq,varC]=MakeVQ(X,Ncodes)vq=init(VQ,X,Ncodes);%create a random codebook of the right size[vq,varC]=trainLloyd(vq,X);%and train it using same data